//
//  addNewFriendDetailVC.m
//  HappyStore
//
//  Created by 陈锋 on 16/7/18.
//  Copyright © 2016年 LLJ. All rights reserved.
//

#import "addNewFriendDetailVC.h"

#import "thirPersonSecCell.h"
#import "myProfileCell.h"
#import "PersonProfileCell.h"
#import "hobbyCell.h"
#import "workCell.h"
#import "companyProfileFirCell.h"
#import "companyProfileSecCell.h"
#import "companyMyProfileCell.h"
#import "HeadView.h"
#import "FriendViewController.h"
#import "sessionVC.h"
#import "Recruitment.h"
#import "issuedVC.h"

@interface addNewFriendDetailVC (){

    NSMutableArray *dataArr;
    NSDictionary * pageDict;
    NSMutableArray* hobbyArr;
    NSMutableArray * numberArr;

}
@property (strong, nonatomic) HeadView *headView;
@property (strong, nonatomic) NSMutableDictionary * dicData;
@end

static NSString * myProfilecell = @"myProfileCell";
static NSString * hobbycell = @"hobbyCell";
static NSString * workcell = @"workCell";
static NSString * companyProfileFircell = @"companyProfileFirCell";
static NSString * companyProfileSeccell = @"companyProfileSecCell";
static NSString * companyMyProfilecell = @"companyMyProfileCell";

@implementation addNewFriendDetailVC

-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:YES];
    
    // 设置头视图
    [self setData];
    
    [self setFootView];
    
    [self sendRequest];

}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"详细信息";
    
    //设置返回按钮
    UIBarButtonItem *leftItem = [UIBarButtonItem itemWithTarget:self action:@selector(leftBarButtonItemClick) image:@"Back" highImage:@"Back"];
    self.navigationItem.leftBarButtonItem = leftItem;
    
    // 注册
    UINib * nib = [UINib nibWithNibName:@"PersonProfileCell" bundle:nil];
    [self.tableView registerNib:nib forCellReuseIdentifier:myProfilecell];
    
    UINib * nib2 = [UINib nibWithNibName:@"hobbyCell" bundle:nil];
    [self.tableView registerNib:nib2 forCellReuseIdentifier:hobbycell];
    
    UINib * nib3 = [UINib nibWithNibName:@"workCell" bundle:nil];
    [self.tableView registerNib:nib3 forCellReuseIdentifier:workcell];
    
    UINib * nib4 = [UINib nibWithNibName:@"companyProfileFirCell" bundle:nil];
    [self.tableView registerNib:nib4 forCellReuseIdentifier:companyProfileFircell];
    
    UINib * nib5 = [UINib nibWithNibName:@"companyProfileSecCell" bundle:nil];
    [self.tableView registerNib:nib5 forCellReuseIdentifier:companyProfileSeccell];
    
    UINib *nib6 = [UINib nibWithNibName:@"companyMyProfileCell" bundle:nil];
    [self.tableView registerNib:nib6 forCellReuseIdentifier:companyMyProfilecell];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    [self setUpListenEvent];
    
}

-(void)leftBarButtonItemClick{
    
    FriendViewController * FriendView  = [[FriendViewController alloc]init];
    FriendView.TagerUserId = nil;

    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    if ([self.userType integerValue] == 1) {//个人
        
        return 3;
    }else if ([self.userType integerValue] == 2) {//企业
        
        return 2;
        
    }else return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if ([self.userType integerValue] == 1) {//个人
        
        if (section == 0) {
            return 1;
        }else if(section == 1){
            return 1;
        }else if (section == 2){
            return 1;
        }
        
        else return 0;
        
    }else if ([self.userType integerValue] == 2) {//企业
        
        return 1;
        
    }else return 0;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

        return 10;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([self.userType integerValue] == 1) {//个人
        
        if (indexPath.section == 0) {
            return 60;
        }
        
        else if (indexPath.section == 1) {
            UILabel *label = [[UILabel alloc] init];
            label.numberOfLines = 0;
            if (!self.dicData[@"signature"]) {
                label.text = @"暂无简介";
            }else{
                label.text = self.dicData[@"signature"];
            }
            label.font = [UIFont systemFontOfSize:14];
            CGSize size = [label sizeThatFits:CGSizeMake(228, MAXFLOAT)];
            
            //商务需求
            UILabel *needLabel = [[UILabel alloc] init];
            needLabel.numberOfLines = 0;
            if (!self.dicData[@"myneeds"]) {
                needLabel.text = @"暂无关注领域";
            }else{
                needLabel.text = self.dicData[@"myneeds"];
            }
            needLabel.font = [UIFont systemFontOfSize:14];
            CGSize needSize = [needLabel sizeThatFits:CGSizeMake(228, MAXFLOAT)];
            
            return 130 +size.height + needSize.height;
            //return 170;
        }else if (indexPath.section ==2 ){
            return 80;
        }
        else return 0;
    }else if ([self.userType integerValue] == 2) {//企业
        
        if (indexPath.section ==0) {
            return 60;
        }
        
        else if (indexPath.section == 1) {
            companyProfileFirCell * companyProfileFir = [self tableView:tableView cellForRowAtIndexPath:indexPath];
            //设置字体
            UIFont *font = [UIFont fontWithName:@"Arial" size:14];
            companyProfileFir.detailLabel.font = font;
            companyProfileFir.detailLabel.text = self.dicData[@"introduction"];
            CGSize constraint = CGSizeMake(250, 9999.0f);
            
            CGSize size = [companyProfileFir.detailLabel.text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
            
            [companyProfileFir.detailLabel setFrame:CGRectMake(0, 0, size.width, size.height)];
            
            //设置cell自适应高度
            CGRect cellFrame = [companyProfileFir frame];
            cellFrame.origin = CGPointMake(0, 0);
            CGFloat totalHeight = cellFrame.size.height + companyProfileFir.detailLabel.height - 80;
            cellFrame.size.height = totalHeight;
            [companyProfileFir setFrame:cellFrame];
            
            //return companyProfileFir.frame.size.height;
            return size.height + 60;
        }else if (indexPath.section ==2 ){
            companyMyProfileCell *comCell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
            comCell.needs.text = self.dicData[@"companyBusNeeds"];
            CGSize size = [comCell.needs sizeThatFits:CGSizeMake(228, MAXFLOAT)];
            return 140 + size.height;
        }
        else return 0;
        
    }else return 0;
    
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];//取消选中状态
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.section == 0) {
        thirPersonSecCell *cell = [thirPersonSecCell cellWithTableView:tableView];
        
        for (int i = 0 ; i < cell.mtArr.count; i ++) {
            
            UILabel * label = cell.mtArr[i];
            label.text = numberArr[i];
            
        }
        
        return cell;
    }
    
    
    else if (indexPath.section == 1) {
        
        if ([self.userType integerValue] == 1) {//个人
            
            PersonProfileCell * profileCell = [self.tableView dequeueReusableCellWithIdentifier:myProfilecell];
            
            profileCell.classBtn.hidden = YES;
            
            if (pageDict) {
                
                profileCell.classBtn.hidden = NO;
                profileCell.classCount.text = [NSString stringWithFormat:@"%ld",[pageDict[@"sumCount"]integerValue]];
                profileCell.classTitle.text = dataArr[0][@"content"];
                profileCell.classTime.text = dataArr[0][@"createTime"];
                [profileCell.classImg sd_setImageWithURL:[NSURL URLWithString:dataArr[0][@"photos"][0]]];
                [profileCell.classBtn addTarget:self action:@selector(jumpClass) forControlEvents:UIControlEventTouchUpInside];
                
            }
            
            if ([self.dicData[@"signature"] isEqualToString:@""] || [self.dicData[@"signature"] isEqualToString:@"null"]) {
                
                profileCell.myprofile.text = @"暂无简介";
                
            }else{
                
                profileCell.myprofile.text = self.dicData[@"signature"];
                
            }
            
            if ([self.dicData[@"goodatfield"] isEqualToString:@""] || [self.dicData[@"goodatfield"] isEqualToString:@"null"]) {
                
                profileCell.focus.text = @"暂无关注领域";
                
            }else{
                
                profileCell.focus.text = self.dicData[@"goodatfield"];
                
            }
            
            if ([self.dicData[@"myneeds"] isEqualToString:@""] || [self.dicData[@"myneeds"] isEqualToString:@"null"]) {
                
                profileCell.needs.text = @"暂无需求";
                
            }else{
                
                profileCell.needs.text = self.dicData[@"myneeds"];
                
            }
            
            return profileCell;
            
        }else if ([self.userType integerValue] == 2) {//企业
            
            companyProfileFirCell * companyProfileFir = [self.tableView dequeueReusableCellWithIdentifier:companyProfileFircell];
            
            if ([self.dicData[@"introduction"] isEqualToString:@"null"] || [self.dicData[@"introduction"] isEqualToString:@""]) {
                
                companyProfileFir.detailLabel.text = @"暂未填写";
                
            }else{
                
                companyProfileFir.detailLabel.text = self.dicData[@"introduction"];
                [companyProfileFir.detailLabel setNumberOfLines:0];
                
            }
            
            
            return companyProfileFir;
            
        }else return nil;
        
        
    }else if (indexPath.section == 2){
        
        if ([self.userType integerValue] == 1) {//个人
            
            hobbyCell * hobbyCell = [self.tableView dequeueReusableCellWithIdentifier:hobbycell];
            
            
            if ([self.dicData[@"hobby"] isEqualToString:@""] || [self.dicData[@"hobby"] isEqualToString:@"null"]) {
                
            }else{
                
                for (int i = 0; i < hobbyArr.count; i++) {
                    
                    if (i != hobbyArr.count -1 && i != hobbyArr.count) {
                        
                        UILabel *label =  hobbyCell.hobby[i];
                        //label.layer.masksToBounds = YES;
                        label.layer.borderColor = [UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f].CGColor;
                        label.layer.borderWidth = 0.5f;
                        //label.layer.cornerRadius = 5.0f;
                        label.backgroundColor = [UIColor colorWithRed:210.0/255.0f green:244.0/255.0f blue:255.0/255.0f alpha:1.0f];
                        label.textColor = [UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f];
                        label.text = hobbyArr[i];
                    }
                    
                }
                
                
            }
            
            return hobbyCell;
            
        }else if ([self.userType integerValue] == 2) {//企业
            
            companyMyProfileCell * profileCell = [self.tableView dequeueReusableCellWithIdentifier:companyMyProfilecell];
            
            profileCell.classBtn.hidden = YES;
            
            if (pageDict) {
                
                profileCell.classBtn.hidden = NO;
                profileCell.classCount.text = [NSString stringWithFormat:@"%ld",[pageDict[@"sumCount"]integerValue]];
                profileCell.classTitle.text = dataArr[0][@"content"];
                profileCell.classTime.text = dataArr[0][@"createTime"];
                [profileCell.classImg sd_setImageWithURL:[NSURL URLWithString:dataArr[0][@"photos"][0]]];
                [profileCell.classBtn addTarget:self action:@selector(jumpClass) forControlEvents:UIControlEventTouchUpInside];
                
            }
            
            
            if ([self.dicData[@"companyField"] isEqualToString:@""] || [self.dicData[@"companyField"] isEqualToString:@"null"]) {
                
                profileCell.focus.text = @"暂无关注领域";
                
            }else{
                
                profileCell.focus.text = self.dicData[@"companyField"];
                
            }
            
            if ([self.dicData[@"companyBusNeeds"] isEqualToString:@""] || [self.dicData[@"companyBusNeeds"] isEqualToString:@"null"]) {
                
                profileCell.needs.text = @"暂无需求";
                
            }else{
                
                profileCell.needs.text = self.dicData[@"companyBusNeeds"];
                
            }
            
            return profileCell;
            
        }else return nil;
        
        
    }
    
    else return  nil;
}

-(void)setFootView{

    UIView * footView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenW, 120)];
    footView.backgroundColor = [UIColor whiteColor];
    
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(20, 20, screenW - 40, 40)];
    button.layer.masksToBounds = YES;
    button.layer.cornerRadius = 5.0f;
    
    UIButton * cancelBtn = [[UIButton alloc]init];
    
    if (self.addType) {
        
        if ([self.addType isEqualToString:@"申请方"] && [self.btnType isEqualToString:@"0"]) {
            
            [button setTitle:@"等待验证" forState:0];
            [button setTitleColor:[UIColor whiteColor] forState:0];
            [button setBackgroundColor:[UIColor lightGrayColor]];
            
        }else{
            
            if ([self.btnType isEqualToString:@"0"]) {
                
                [button setTitle:@"通过验证" forState:0];
                [button setTitleColor:[UIColor whiteColor] forState:0];
                [button setBackgroundColor:[UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f]];
                
                cancelBtn.frame = CGRectMake(20, button.y + button.height + 20, screenW - 40, 40);
                
                cancelBtn.layer.masksToBounds = YES;
                cancelBtn.layer.cornerRadius = 5.0f;
                [cancelBtn setTitle:@"拒绝添加" forState:0];
                [cancelBtn setTitleColor:[UIColor whiteColor] forState:0];
                [cancelBtn setBackgroundColor:[UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f]];
                [cancelBtn addTarget:self action:@selector(clickCancel:) forControlEvents:UIControlEventTouchUpInside];
                
                [footView addSubview:cancelBtn];
                
            }else if ([self.btnType isEqualToString:@"1"]){
                
                [button setTitle:@"发消息" forState:0];
                [button setTitleColor:[UIColor whiteColor] forState:0];
                [button setBackgroundColor:[UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f]];
                
            }else if ([self.btnType isEqualToString:@"2"]){
                
                [button setTitle:@"已拒绝" forState:0];
                [button setTitleColor:[UIColor whiteColor] forState:0];
                [button setBackgroundColor:[UIColor lightGrayColor]];
                button.userInteractionEnabled = NO;
                
            }
            
            [button addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
            
        }
        
        [footView addSubview:button];
        
    }else if(self.creatorId){
    
        [button setTitle:@"移除讨论组" forState:0];
        [button setTitleColor:[UIColor whiteColor] forState:0];
        [button setBackgroundColor:[UIColor colorWithRed:0.0/255.0f green:180.0/255.0f blue:222.0/255.0f alpha:1.0f]];
        button.userInteractionEnabled = YES;
        [button addTarget:self action:@selector(clickBtn:) forControlEvents:UIControlEventTouchUpInside];
        
        [footView addSubview:button];
    
    }
    
    
    self.tableView.tableFooterView = footView;
    self.tableView.tableFooterView.userInteractionEnabled = YES;

}

-(void)clickBtn:(UIButton *)button{

    if ([button.titleLabel.text isEqualToString:@"通过验证"]) {
        
        [self showRoundProgressWithTitle:@"请稍后..."];
        
        NSMutableDictionary * dic = [NSMutableDictionary  dictionary];
        
        dic[@"userId"] = allConstMemberid;
        
        dic[@"token"] = allConstMemberToken;
        
        dic[@"TagerUserId"] = self.userId;
        
        dic[@"type"] = @(1);
        
        [LSHttpTool sendHttpData:@"Add_Delete_Friend_app_social.im.lensum" params:dic success:^(id responseObject) {
            
            NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
            //
            //        NSString * jsonStr = [LSHttpTool DataTOjsonString:dicInfo];
            //        NSLog(@"--------------------json:%@",jsonStr);
            
            
            if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {

                [self showRightWithTitle:[dicInfo objectForKey:@"msg"] autoCloseTime:2];
                
            }else{

                [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
                
            }
            
        } failure:^(NSError *error) {

           [self showSingleIconBubble:@"网络连接错误"];

            
        }];
        
        self.btnType = @"1";
        self.tableView.tableFooterView = nil;
        [self setFootView];
        [self.tableView reloadData];
        
    }else if ([button.titleLabel.text isEqualToString:@"发消息"]){
        
        IQKeyboardManager *manager = [IQKeyboardManager sharedManager];
        manager.enable = NO;
        manager.shouldResignOnTouchOutside = NO;
        manager.shouldToolbarUsesTextFieldTintColor = NO;
        manager.enableAutoToolbar = NO;
    
        sessionVC *chatVc = [[sessionVC alloc] init];
        chatVc.title = _dicData[@"userName"];
        chatVc.conversationType = ConversationType_PRIVATE;
        chatVc.targetId = _dicData[@"account"];
        chatVc.enableUnreadMessageIcon = YES;
        chatVc.enableNewComingMessageIcon = YES;
        chatVc.defaultHistoryMessageCountOfChatRoom = 50;
        
        [self.navigationController pushViewController:chatVc animated:YES];
        
    }else if ([button.titleLabel.text isEqualToString:@"移除讨论组"]){
        
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"确定将成员移除讨论组吗?" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
        alert.alertViewStyle = UIAlertViewStyleDefault;
        
        [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
            
            if(buttonIndex == 1){
            
                [[RCIMClient sharedRCIMClient] removeMemberFromDiscussion:self.discussionId userId:self.account success:^(RCDiscussion *discussion) {
                    
                    NSMutableDictionary * dictData = [NSMutableDictionary dictionary];
                    
                    // 移除成员
                    
                    [dictData setValue:allConstMemberToken forKey:@"token"];
                    [dictData setValue:self.discussionId forKey:@"groupId"];
                    [dictData setValue:self.userId forKey:@"userId"];
                    
                    NSString *str = @"outCircle_app_social.im.lensum?";
                    
                    [LSHttpTool sendHttpData:str params:dictData success:^(id responseObject) {
                        
                        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
                        
                        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                            
                            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"已成功将用户移除讨论组!" delegate:self cancelButtonTitle:@"知道了" otherButtonTitles: nil];
                            
                            [alert show];
                            
                            [self.navigationController popViewControllerAnimated:YES];
                            
                        }
                        
                        
                    } failure:^(NSError *error) {

                        [self showSingleIconBubble:@"网络连接错误"];
                        
                    }];
                    
                    
                } error:^(RCErrorCode status) {
                    
                    NSLog(@"create discussion Failed &gt; %ld!", (long)status);
                    
                }];
                
                NSLog(@"点击移除讨论组");
            
            }
            
        }];

    }

}

-(void)clickCancel:(UIButton *)button{
    
    [self showRoundProgressWithTitle:@"请稍后..."];
    
    NSMutableDictionary * dic = [NSMutableDictionary  dictionary];
    
    dic[@"userId"] = allConstMemberid;
    
    dic[@"token"] = allConstMemberToken;
    
    dic[@"TagerUserId"] = self.userId;
    
    dic[@"type"] = @(2);

    [LSHttpTool sendHttpData:@"Add_Delete_Friend_app_social.im.lensum" params:dic success:^(id responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        //
        //        NSString * jsonStr = [LSHttpTool DataTOjsonString:dicInfo];
        //        NSLog(@"--------------------json:%@",jsonStr);
        
        
        
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {

            [self showRightWithTitle:[dicInfo objectForKey:@"msg"] autoCloseTime:2];
            
        }else{

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
            
        }
        
    } failure:^(NSError *error) {

        [self showSingleIconBubble:@"网络连接错误"];
        
    }];

    self.btnType = @"2";
    [self setFootView];
    [self.tableView reloadData];

}

-(void)sendRequest{
    NSMutableDictionary * dic = [NSMutableDictionary  dictionary];

    
    dic[@"userId"] = allConstMemberid;
    
    //    }
    dic[@"TagerUserId"] = self.userId;
    
    dic[@"page"] = @(1);

    [LSHttpTool sendHttpData:@"getCibdList_app_cibd.im" params:dic success:^(id responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        //
        //        NSString * jsonStr = [LSHttpTool DataTOjsonString:dicInfo];
        //        NSLog(@"--------------------json:%@",jsonStr);
        
        
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            
            pageDict = dicInfo[@"data"][@"page"];
            dataArr = dicInfo[@"data"][@"record"];
            [self.tableView reloadData];

        }else{
            
        }
        
    } failure:^(NSError *error) {

       [self showSingleIconBubble:@"网络连接错误"];
        
    }];
    
}

-(void)setData{
    self.headView = [[[NSBundle mainBundle] loadNibNamed:@"HeadView" owner:self options:nil] lastObject];
    
    
    [self showRoundProgressWithTitle:@"请稍后..."];
    
    //token=rE3F2m8AvfC7CVh85O9q&userId=9&userType=用户类型 1-个人，2-企业，3-政府
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:self.userId forKey:@"userId"];//用户类型 1-个人，2-企业，3-政府
    
    if (allConstMemberid) {
        [muDicParameters setObject:allConstMemberid forKey:@"MyUserId"];
    }
    
    [muDicParameters setObject:self.userType forKey:@"userType"];//验证用户
    
    NSString *strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"MyBasicMessage_app_myHome.im"];
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        //        NSString * jsonStr = [LSHttpTool DataTOjsonString:dicInfo];
        //        NSLog(@"--------------------json:%@",jsonStr);
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            _dicData = dicInfo[@"data"];
            
            
            [self.headView.imgStr sd_setImageWithURL:[NSURL URLWithString:_dicData[@"headPhoto"]]];
            
            
            if (_dicData[@"userName"] == [NSNull null] || [_dicData[@"userName"] isEqualToString:@"null"]) {
                
                self.headView.nameStr.text = _dicData[@"account"];
                
            }else {
                self.headView.nameStr.text = _dicData[@"userName"];
                
            }
            
            
            if ([self.userType integerValue] == 1) {//个人
                
                //positionName-
                //goveAccount 政府账户
                //companyAccount 企业帐户
                
                if (_dicData[@"positionName"] == [NSNull null] || [_dicData[@"positionName"] isEqualToString:@"null"]) {
                    self.headView.positionNameStr.text = @" ";
                    
                }else {
                    self.headView.positionNameStr.text = _dicData[@"positionName"];
                }
                
                
                if (_dicData[@"companyAccount"] == nil || [_dicData[@"companyAccount"] isEqualToString:@""]||[_dicData[@"companyAccount"] isEqualToString:@"null"]) {
                    if (_dicData[@"goveAccount"] == nil || [_dicData[@"goveAccount"] isEqualToString:@""] || [_dicData[@"goveAccount"] isEqualToString:@"null"]) {
                        //------没有上级
                        self.headView.companyUserNameStr.text = @"";
                    }else{
                        if (_dicData[@"goveUserName"]==nil ||[_dicData[@"goveUserName"] isEqualToString:@""]||[_dicData[@"goveUserName"] isEqualToString:@"null"]) {
                            self.headView.companyUserNameStr.text = _dicData[@"goveAccount"];
                        }else{
                            self.headView.companyUserNameStr.text = _dicData[@"goveUserName"];
                        }
                    }
                }else{
                    if (_dicData[@"companyUserName"]==nil ||[_dicData[@"companyUserName"] isEqualToString:@""]||[_dicData[@"companyUserName"] isEqualToString:@"null"]) {
                        self.headView.companyUserNameStr.text = _dicData[@"companyAccount"];
                    }else{
                        self.headView.companyUserNameStr.text = _dicData[@"companyUserName"];
                    }
                    
                }
                
            }else if ([self.userType integerValue] == 2) {//企业
                
                //positionName-
                //goveAccount 政府账户
                //companyAccount 企业帐户
                
                self.headView.positionNameStr.text = @"";
                
                if (_dicData[@"companyAccount"] == nil || [_dicData[@"companyAccount"] isEqualToString:@""]||[_dicData[@"companyAccount"] isEqualToString:@"null"]) {
                    //没上级
                    self.headView.companyUserNameStr.text = _dicData[@"address"];
                }else{
                    if (_dicData[@"companyUserName"]==nil ||[_dicData[@"companyUserName"] isEqualToString:@""]||[_dicData[@"companyUserName"] isEqualToString:@"null"]) {
                        self.headView.companyUserNameStr.text = _dicData[@"companyAccount"];
                    }else{
                        self.headView.companyUserNameStr.text = _dicData[@"companyUserName"];
                    }
                    
                }
                
            }
            if ([_dicData[@"authState"] integerValue] == 2) {
                self.headView.vStr.image =[UIImage imageNamed:@"yirenzheng"];
            }else{
                self.headView.vStr.image =[UIImage imageNamed:@"weirenzheng"];
            }
            if ([_dicData[@"mobile"] isEqualToString:@"null"] || [_dicData[@"mobile"] isEqualToString:@""]) {
                
                self.headView.phoneStr.text = @"暂未添加";
            }else{
                self.headView.phoneStr.text = _dicData[@"mobile"];
            }
            if ([_dicData[@"email"] isEqualToString:@""] || [_dicData[@"email"] isEqualToString:@"null"]) {
                
                self.headView.emailStr.text = @"暂未添加邮箱";
                
            }else{
                self.headView.emailStr.text = _dicData[@"email"];
            }
            
            CGSize nameSize = [self.headView.nameStr sizeThatFits:CGSizeMake(MAXFLOAT, 20)];
            if (self.headView.nameConstraint.constant == 220) {
                if (nameSize.width > 192) {
                    self.headView.nameConstraint.constant -= 192;
                }else{
                    self.headView.nameConstraint.constant -= nameSize.width;
                }
            }
            
            CGSize nameSizeCon = [self.headView.nameStr sizeThatFits:CGSizeMake(192, MAXFLOAT)];
            self.headView.frame = CGRectMake(0, 0, screenW, self.headView.height - self.headView.nameStr.height + nameSizeCon.height);

            hobbyArr = [[self.dicData[@"hobby"] componentsSeparatedByString:@","] copy];
            
            NSMutableArray * othernumberArr = [NSMutableArray array];
            
            [othernumberArr addObject:_dicData[@"projectNumber"]];
            [othernumberArr addObject:_dicData[@"fundsNumber"]];
            [othernumberArr addObject:_dicData[@"activityNumber"]];
            [othernumberArr addObject:_dicData[@"jobhuntingNumber"]];
            [othernumberArr addObject:_dicData[@"serviceNumber"]];
            numberArr = othernumberArr;
            
            self.tableView.tableHeaderView = self.headView;
            [self.headView.imgBtn addTarget:self action:@selector(clickHeadImg) forControlEvents:UIControlEventTouchUpInside];
            
            [self hideBubble];
            [self.tableView reloadData];
            
        }else {

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];

        }
        
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {

        [self showSingleIconBubble:error.localizedDescription];

    }];
    
}

-(void)clickHeadImg{
    
    NSMutableArray *photos = [NSMutableArray array];
    MJPhotoBrowser *browser = [[MJPhotoBrowser alloc] init];
    MJPhoto *photo = [[MJPhoto alloc] init];
    photo.url = [NSURL URLWithString:_dicData[@"headPhoto"]];
    photo.srcImageView = self.headView.imgStr;
    [photos addObject:photo];
    browser.photos = photos;
    
    [browser show];
    
}

#pragma mark - jump
-(void)jumpClass{
    
    FriendViewController * FriendView = [[FriendViewController alloc]init];
    FriendView.TagerUserId = self.userId;
    
    
    [self.navigationController pushViewController:FriendView animated:YES];
    
}

#pragma mark - 监听通知
-(void)setUpListenEvent{
    
    //分类通知
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(clickCategoryChange:) name:@"clicktThirPerson" object:nil];
}
-(void)clickCategoryChange:(NSNotification *)notification{
    NSString * cityName = notification.userInfo[@"category"];
    
    if ([cityName isEqualToString:@"招聘"]) {
        
        UIStoryboard *sb=[UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
        
        Recruitment * recruitment = [sb instantiateViewControllerWithIdentifier:@"Recruitment"];
        
        recruitment.typeTitle = @"招聘求职";
        recruitment.userId = self.dicData[@"userId"];
        recruitment.userType = self.dicData[@"userType"];
        recruitment.navigationController.navigationBarHidden = YES;
        
        [self.navigationController pushViewController:recruitment animated:YES];
        
    }else{
        
        issuedVC * issued = [[issuedVC alloc]init];
        issued.titleStr = cityName;
        issued.userType = self.dicData[@"userType"];
        issued.userId = self.dicData[@"userId"];
        [self.navigationController pushViewController:issued animated:YES];
        
    }
    
    NSLog(@"%@",cityName);
}
@end
